import { RouteRecordRaw } from "vue-router";

/**
 * 路由meta对象参数说明
 * meta: {
 *      title:          菜单栏及 tagsView 栏、菜单搜索名称（国际化）
 *      isLink：        是否超链接菜单，开启外链条件，`1、isLink:true 2、链接地址不为空`
 *      isHide：        是否隐藏此路由
 *      isKeepAlive：   是否缓存组件状态
 *      isAffix：       是否固定在 tagsView 栏上
 *      isIframe：      是否内嵌窗口，，开启条件，`1、isIframe:true 2、链接地址不为空`
 *      roles：         当前路由权限标识，取角色管理。控制路由显示、隐藏。超级管理员：admin 普通角色：common
 *      icon：          菜单、tagsView 图标，阿里：加 `iconfont xxx`，fontawesome：加 `fa xxx`
 * }
 */

/**
 * 定义动态路由
 * @description 未开启 isRequestRoutes 为 true 时使用（前端控制路由），开启时第一个顶级 children 的路由将被替换成接口请求回来的路由数据
 * @description 各字段请查看 `/@/views/system/menu/component/addMenu.vue 下的 ruleForm`
 * @returns 返回路由菜单数据
 */
export const dynamicRoutes = [
  // export const dynamicRoutes: Array<RouteRecordRaw> = [
  {
    path: "/",
    name: "/",
    // component: () => import("/@/layout/index.vue"),
    redirect: "/home",
    meta: {
      isKeepAlive: true,
    },
    children: [
      {
        path: "/home",
        name: "home",
        // component: () => import("/@/views/home/index.vue"),
        meta: {
          title: "首页",
          isLink: "",
          isHide: false,
          isKeepAlive: true,
          isAffix: true,
          isIframe: false,
          roles: ["admin", "common"],
          icon: "iconfont icon-shouye",
        },
      },

      {
        path: "/designer/model",
        name: "funIndex",
        // component: () => import("/@/layout/routerView/parent.vue"),
        redirect: "/designer/model",
        meta: {
          title: "模型",
          isLink: "",
          isHide: false,
          isKeepAlive: true,
          isAffix: false,
          isIframe: false,
          roles: ["admin", "common"],
          icon: "iconfont icon-crew_feature",
        },
      },
      {
        path: "/fun/splitpanes",
        name: "funIndex",
        // component: () => import("/@/layout/routerView/parent.vue"),
        redirect: "/fun/splitpanes",
        meta: {
          title: "组件",
          isLink: "",
          isHide: false,
          isKeepAlive: true,
          isAffix: false,
          isIframe: false,
          roles: ["admin", "common"],
          icon: "iconfont icon-crew_feature",
        },
        children: [
          {
            path: "/fun/splitpanes",
            name: "funSplitpanes",
            // component: () => import("/@/views/fun/splitpanes/index.vue"),
            meta: {
              title: "分栏",
              isLink: "",
              isHide: false,
              isKeepAlive: true,
              isAffix: false,
              isIframe: false,
              roles: ["admin", "common"],
              icon: "iconfont icon--chaifenlie",
            },
          },
        ],
      },
    ],
  },
];

/**
 * 定义静态路由
 * @description 前端控制直接改 dynamicRoutes 中的路由）
 * @returns 返回路由菜单数据
 * : Array<RouteRecordRaw> =
 */
export const staticRoutes = [
  {
    path: "/login",
    name: "login",
    // component: () => import("/@/views/login/index.vue"),
    meta: {
      title: "登录",
    },
  },
  {
    path: "/404",
    name: "notFound",
    // component: () => import("/@/views/error/404.vue"),
    meta: {
      title: "message.staticRoutes.notFound",
    },
  },
];
